package org.martin.snsrs.client.model;

import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

public class Entity {
	
	protected String status;
	
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getErrorReason() {
		return errorReason;
	}

	public void setErrorReason(String errorReason) {
		this.errorReason = errorReason;
	}

	public boolean isSuccess() {
		return isSuccess;
	}

	public void setSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	protected String errorReason;
	
	protected boolean isSuccess;
	
	public Entity(JSONObject object){
		onParse(object);
	}
	
	protected void onParse(JSONObject object){
		try {
			status = object.getString("status");
			if(status.equals("error")){
				isSuccess = false;
				errorReason = object.getString("errorReason");
			}
			else {
				isSuccess = true;
			}
		} catch (JSONException e) {
			e.printStackTrace();
			isSuccess = true;
		}
	}
}
